<?php

class Admin_Form_Login extends Twitter_Bootstrap_Form_Horizontal
{

    public function getFormId() {
        $className = get_class($this);
        return strtolower($className);
    }

    public function init()
    {
        $this->setIsArray(true);
        //$this->setElementsBelongTo('bootstrap');

        $this->_addClassNames('form-login');

        // Username
        $this->addElement('text', 'username', array(
            'id' => $this->getFormId().'_username',
            'placeholder' => $this->getView()->translate('LOGIN_ID'),
            'prepend' => 'icon-user',
            'class' => 'span3',
            'maxlength' => 45
        ));
        $this->getElement('username')
        ->addFilter('StringTrim')
        ->setRequired(true)
        ->addValidators(array(
            array('NotEmpty', true),
            array('alnum'),
            array('stringLength', false, array(4, 20)),
        ));

        // Password
        $this->addElement('password', 'password', array(
            'id' => $this->getFormId().'_password',
            'placeholder' => $this->getView()->translate('LOGIN_PASSWD'),
            'prepend' => 'icon-lock',
            'class' => 'span3',
            'maxlength' => 255,
            'autocomplete' => 'off'
        ));
        $this->getElement('password')
        ->setRequired(true)
        ->addValidators(array(
            array('NotEmpty', true),
            array('stringLength', false, array(6, 255)),
        ));
    }

}